home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Libraries / GammaPasLib 1.1 / gammaPasLibIntf.p < prev    next >
Encoding:
Text File  |  1993-07-20  |  4.8 KB  |  147 lines  |  [TEXT/PJMM]

  1. {-------------------------------------------------------------------------------}
  2. {Gamma utils by Matt Slot                                                                        }
  3. {                                                                                                      }
  4. {      This library is intended as a general tool for manipulating the Gamma Tables            }
  5. {          of Graphics Devices, to ramp them up or down in order to achieve smooth            }
  6. {          screen fades. The source is included for programmers who want to convert        }
  7. {          the library to A4-based, but it is not commented for public consumption.            }
  8. {      The library defines 2 globals to save state data, but the entire Table                     }
  9. {          manipulation is performed with unlocked handles to be easy on your heap.            }
  10. {          The typical memory chunk is about 600 bytes for a 13" Monitor in 8-bit             }
  11. {          depth, or about 1700 bytes for one in 24-bit color. Usage will vary.                }
  12. {      Of course, the Classic Mac cannot use Gamma Fades, only Mac II or later machines    }
  13. {          with attached monitors. (I don't know about the Color Classic tho’!). Also,            }
  14. {          GDevice manipulation needs to follow InitGraf() & InitWindows() calls.                }
  15. {      Please use the listed functions to see if you can use this code before you set            }
  16. {          it up. As usual, this stuff is not warranteed, guaranteed, or anything--            }
  17. {          use it at your own risk. It is not Apple-recommended for anything, but it            }
  18. {          worked for me, so there!                                                                }
  19. {                                                                                                      }
  20. {          Written:    12/17/92, Matt Slot, fprefect@engin.umich.edu                            }
  21. {-------------------------------------------------------------------------------}
  22. {    Ported to pascal by Matthew Xavier Mora                                                    }
  23. {    mxmora@unix.sri.com                                                                        }
  24. {    07-20-93                                                                                        }
  25. {-------------------------------------------------------------------------------}
  26.  
  27. unit gammaPasLibIntf;
  28.  
  29. interface
  30.  
  31.     const
  32.         kGammaUtilsSig = 'GAMA';                            {A quick signature}
  33.         kGetDeviceListTrapNum = $AA29;                    {To help check    for compatibility }
  34.  
  35.     function IsGammaAvailable: integer;
  36.     function IsOneGammaAvailable (theGDevice: GDHandle): Boolean;
  37.     function SetupGammaTools: OSErr;
  38.     function DisposeGammaTools: OSErr;
  39.     function DoGammaFade (percent: integer): OSErr;
  40.     function DoOneGammaFade (theGDevice: GDHandle; percent: integer): OSErr;
  41.     function GetDevGammaTable (theGDevice: GDHandle; var theTable: GammaTblPtr): OSErr;
  42.     function SetDevGammaTable (theGDevice: GDHandle; var theTable: GammaTblPtr): OSErr;
  43.     function GammaAvail: Boolean;
  44. {-------------------------------------------------------}
  45.     procedure DelayFadeToBlack (delayTicks: longint);
  46.     procedure FadeToBlack (speed: integer);
  47.     procedure FadeFromBlack (speed: integer);
  48.     procedure DelayFadeFromBlack (delayTicks: longint);
  49. {-------------------------------------------------------}
  50.  
  51.  
  52. implementation
  53.     function IsGammaAvailable: integer;
  54.     external;
  55.     function IsOneGammaAvailable (theGDevice: GDHandle): Boolean;
  56.     external;
  57.  
  58.  
  59.     function SetupGammaTools: OSErr;
  60.     external;
  61.     function DisposeGammaTools: OSErr;
  62.     external;
  63.  
  64.     function DoGammaFade (percent: integer): OSErr;
  65.     external;
  66.     function DoOneGammaFade (theGDevice: GDHandle; percent: integer): OSErr;
  67.     external;
  68.  
  69.  
  70.     function GetDevGammaTable (theGDevice: GDHandle; var theTable: GammaTblPtr): OSErr;
  71.     external;
  72.     function SetDevGammaTable (theGDevice: GDHandle; var theTable: GammaTblPtr): OSErr;
  73.     external;
  74.  
  75. {A cheezy function to use pascal true and false}
  76.     function GammaAvail: boolean;
  77.     begin
  78.         if (IsGammaAvailable = 0) then
  79.             GammaAvail := false
  80.         else
  81.             GammaAvail := true;
  82.     end;
  83. {-------------------------------------------------------}
  84.     procedure DelayFadeToBlack (delayTicks: longint);
  85. {-------------------------------------------------------}
  86.         var
  87.             i: integer;
  88.             oe: integer;
  89.             finalTicks: longint;
  90.     begin
  91.         i := 100;
  92.         while i > 0 do
  93.             begin
  94.                 oe := DoGammaFade(i);
  95.                 i := i - 1;
  96.                 Delay(delayTicks, finalTicks);
  97.             end;
  98.     end;
  99.  
  100. {-------------------------------------------------------}
  101.     procedure FadeToBlack (speed: integer);
  102. {-------------------------------------------------------}
  103.         var
  104.             i: integer;
  105.             oe: integer;
  106.             finalTicks: longint;
  107.     begin
  108.         i := 100;
  109.         while (i >= 0) do
  110.             begin
  111.                 oe := DoGammaFade(i);
  112.                 i := i - speed;
  113.             end;
  114.     end;
  115. {-------------------------------------------------------}
  116.     procedure FadeFromBlack (speed: integer);
  117. {-------------------------------------------------------}
  118.         var
  119.             i: integer;
  120.             oe: integer;
  121.             finalTicks: longint;
  122.     begin
  123.         i := 0;
  124.         while (i <= 100) do
  125.             begin
  126.                 oe := DoGammaFade(i);
  127.                 i := i + speed;
  128.             end;
  129.     end;
  130. {-------------------------------------------------------}
  131.     procedure DelayFadeFromBlack (delayTicks: longint);
  132. {-------------------------------------------------------}
  133.         var
  134.             i: integer;
  135.             oe: integer;
  136.             finalTicks: longint;
  137.     begin
  138.         i := 0;
  139.         while (i <= 100) do
  140.             begin
  141.                 oe := DoGammaFade(i);
  142.                 i := i + 1;
  143.                 Delay(delayTicks, finalTicks);
  144.             end;
  145.     end;
  146.  
  147. end.